package model;
import java.util.ArrayList;
import java.io.*;


public class Sort {
    ArrayList<Edge> _edges = new ArrayList<Edge>();
    Node _node;
    Edge _edge;
    
    String _name;
    String _stateChanges;
    String _nodeDescription;
    String _parameters;
    
    String _edgeDescription;
    String _endNodeName;
    String _condition;
    String _delay;
    String _priority;
    String _attributes;
    
    public Sort(int totalNumOfProcedures) {
        makeNode(totalNumOfProcedures);
    }
    
    public void makeNode(int totalNumOfProcedures) {
        /*
         * Make the node
         */
        _name = "SORT";
        _nodeDescription = "";
        _stateChanges = "QPRD[NEXTPRD]=QPRD[NEXTPRD]+1";
        _parameters = "NEXTPRD";
        
        _node = new Node(_name, _nodeDescription, _stateChanges, _parameters);
        
        /*
         * SORT -> _START
         */
        for (int procedureCounter = 0; procedureCounter <= totalNumOfProcedures; procedureCounter++) {
            _edgeDescription = "";
            _endNodeName = "P" + procedureCounter + "_START";
            _condition = "NEXTPRD==" + procedureCounter + "&&STAFF>0";
            _delay = "0";
            _priority = "";
            _attributes = "";
            
            _edge = new Edge(_edgeDescription, _name, _endNodeName, _condition, _delay, _priority, _attributes);
            _edges.add(_edge);
        }
        
        /*
         * SORT -> LEAVE
         */
        _edgeDescription = "";
        _endNodeName = "LEAVE";
        _condition = "NEXTPRD==0";
        _delay = "0";
        _priority = "";
        _attributes = "";
        
        _edge = new Edge(_edgeDescription, _name, _endNodeName, _condition, _delay, _priority, _attributes);
        _edges.add(_edge);
    }
    
    public void outputNode() {
        
    }
    
    public void outputEdge() {
        
    }
}
